import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/page/Home/Home.vue'
import Forum from '../views/page/Forum/Forum.vue'
import Cart from '../views/page/Cart/Cart.vue'
import My from '../views/page/My/My.vue'
import Login from '../views/page/Login/Login.vue'
//解决已经在当前页面的时候 又push到当前页面 报错的问题。
import Router from 'vue-router'
const routerPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error=> error)
}

Vue.use(VueRouter)


const routes = [
  {
    path: '/',
    name: 'home',
    component: Home
  },
  {
    path: '/forum',
    name: 'forum',
    component: Forum
  },
  {
    path: '/cart',
    name: 'cart',
    component: Cart
  },
  {
    path: '/my',
    name: 'my',
    component: My
  },
  {
    path: '/login',
    name: 'login',
    component: Login
  },
]
 
const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes,
  // render: h => h(App) //自己参照网上后加
})

export default router

